package cn.gson.springboot.model.pojos;

import javax.persistence.*;
import java.sql.Date;
import java.util.Collection;
import java.util.List;
import java.util.Objects;

@Entity
@Table(name = "employee_", schema = "crm")
public class Employee {
    private int empId;
    private String empName;
    private String empPwd;
    private String empSex;
    private Date empHireDate;
    private double empSalary;
    private String empTel;
    private String isTakeOn;
    private String empImg;
    private Collection<Complain> complainsByEmpId;
    private Collection<Contract> contractsByEmpId;
    private Collection<Customercare> customercaresByEmpId;
    private Collection<Customerservice> customerservicesByEmpId;
    private Collection<Maintenance> maintenancesByEmpId;
    private Collection<Opportunity> opportunitiesByEmpId;
    private Collection<Purchase> purchasesByEmpId;
    private Collection<Qa> qasByEmpId;
    private Department department;
    private Job job;


    @Id
    @Column(name = "emp_id", nullable = false)
    public int getEmpId() {
        return empId;
    }

    public void setEmpId(int empId) {
        this.empId = empId;
    }

    @Basic
    @Column(name = "emp_name", nullable = true, length = 255)
    public String getEmpName() {
        return empName;
    }

    public void setEmpName(String empName) {
        this.empName = empName;
    }

    @Basic
    @Column(name = "emp_pwd", nullable = true, length = 255)
    public String getEmpPwd() {
        return empPwd;
    }

    public void setEmpPwd(String empPwd) {
        this.empPwd = empPwd;
    }

    @Basic
    @Column(name = "emp_sex", nullable = true, length = 255)
    public String getEmpSex() {
        return empSex;
    }

    public void setEmpSex(String empSex) {
        this.empSex = empSex;
    }

    @Basic
    @Column(name = "emp_hire_date", nullable = true)
    public Date getEmpHireDate() {
        return empHireDate;
    }

    public void setEmpHireDate(Date empHireDate) {
        this.empHireDate = empHireDate;
    }

    @Basic
    @Column(name = "emp_salary", nullable = true)
    public double getEmpSalary() {
        return empSalary;
    }

    public void setEmpSalary(double empSalary) {
        this.empSalary = empSalary;
    }

    @Basic
    @Column(name = "emp_tel", nullable = true, length = 255)
    public String getEmpTel() {
        return empTel;
    }

    public void setEmpTel(String empTel) {
        this.empTel = empTel;
    }

    @Basic
    @Column(name = "is_take_on", nullable = true)
    public String getIsTakeOn() {
        return isTakeOn;
    }

    public void setIsTakeOn(String isTakeOn) {
        this.isTakeOn = isTakeOn;
    }

    @Basic
    @Column(name = "emp_img", nullable = true)
    public String getEmpImg() {
        return empImg;
    }

    public void setEmpImg(String empImg) {
        this.empImg = empImg;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Employee employee = (Employee) o;
        return empId == employee.empId &&
                Objects.equals(empName, employee.empName) &&
                Objects.equals(empPwd, employee.empPwd) &&
                Objects.equals(empSex, employee.empSex) &&
                Objects.equals(empHireDate, employee.empHireDate) &&
                Objects.equals(empTel, employee.empTel) &&
                Objects.equals(isTakeOn, employee.isTakeOn)&&
                Objects.equals(empImg, employee.empImg);
    }

    @Override
    public int hashCode() {
        return Objects.hash(empId, empName, empPwd, empSex, empHireDate, empTel, isTakeOn);
    }

    @OneToMany(mappedBy = "employeeByEmpId")
    public Collection<Complain> getComplainsByEmpId() {
        return complainsByEmpId;
    }

    public void setComplainsByEmpId(Collection<Complain> complainsByEmpId) {
        this.complainsByEmpId = complainsByEmpId;
    }

    @OneToMany(mappedBy = "employeeByEmpId")
    public Collection<Contract> getContractsByEmpId() {
        return contractsByEmpId;
    }

    public void setContractsByEmpId(Collection<Contract> contractsByEmpId) {
        this.contractsByEmpId = contractsByEmpId;
    }

    @OneToMany(mappedBy = "employeeByEmpId")
    public Collection<Customercare> getCustomercaresByEmpId() {
        return customercaresByEmpId;
    }

    public void setCustomercaresByEmpId(Collection<Customercare> customercaresByEmpId) {
        this.customercaresByEmpId = customercaresByEmpId;
    }

    @OneToMany(mappedBy = "employeeByEmpId")
    public Collection<Customerservice> getCustomerservicesByEmpId() {
        return customerservicesByEmpId;
    }

    public void setCustomerservicesByEmpId(Collection<Customerservice> customerservicesByEmpId) {
        this.customerservicesByEmpId = customerservicesByEmpId;
    }


    @OneToMany(mappedBy = "employeeByEmpId")
    public Collection<Maintenance> getMaintenancesByEmpId() {
        return maintenancesByEmpId;
    }

    public void setMaintenancesByEmpId(Collection<Maintenance> maintenancesByEmpId) {
        this.maintenancesByEmpId = maintenancesByEmpId;
    }

    @OneToMany(mappedBy = "employeeByEmpId")
    public Collection<Opportunity> getOpportunitiesByEmpId() {
        return opportunitiesByEmpId;
    }

    public void setOpportunitiesByEmpId(Collection<Opportunity> opportunitiesByEmpId) {
        this.opportunitiesByEmpId = opportunitiesByEmpId;
    }

    @OneToMany(mappedBy = "employeeByEmpId")
    public Collection<Purchase> getPurchasesByEmpId() {
        return purchasesByEmpId;
    }

    public void setPurchasesByEmpId(Collection<Purchase> purchasesByEmpId) {
        this.purchasesByEmpId = purchasesByEmpId;
    }

    @OneToMany(mappedBy = "employeeByEmpId")
    public Collection<Qa> getQasByEmpId() {
        return qasByEmpId;
    }

    public void setQasByEmpId(Collection<Qa> qasByEmpId) {
        this.qasByEmpId = qasByEmpId;
    }

    @ManyToOne
    @JoinColumn(name = "dept_id" , referencedColumnName = "dept_id")
    public Department getDepartment() {
        return department;
    }

    public void setDepartment(Department department) {
        this.department = department;
    }

    @ManyToOne
    @JoinColumn(name = "job_id", referencedColumnName = "job_id")
    public Job getJob() {
        return job;
    }

    public void setJob(Job job) {
        this.job = job;
    }

    @Override
    public String toString() {
        return "Employee{" +
                "empId=" + empId +
                ", empName='" + empName + '\'' +
                ", empPwd='" + empPwd + '\'' +
                ", empSex='" + empSex + '\'' +
                ", empHireDate=" + empHireDate +
                ", empTel='" + empTel + '\'' +
                ", isTakeOn=" + isTakeOn +
                ", isTakeOn=" + empImg +
                '}';
    }
}
